#include<bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    cin >> s;
 
    int countX = 0;
    int countY = 0;
 
    int ans = 0;
 
    for (const auto &c: s) {
        if (c == 'X') {
            countX++;
        } else {
            countY++;
        }
 
        if (countX == countY) {
            ans++;
        }
    }
 
    cout << ans << endl;
 
    return 0;
}